package com.ruoyi.web.controller.community.integral;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.community.domain.integral.IntAlarms;
import com.ruoyi.community.service.integral.IIntAlarmsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警信息表Controller
 * 
 * @author hanning
 * @date 2021-08-22
 */
@RestController
@RequestMapping("/Integral/alarms")
public class IntAlarmsController extends BaseController
{
    @Autowired
    private IIntAlarmsService intAlarmsService;

    /**
     * 查询报警信息表列表
     */
    @PreAuthorize("@ss.hasPermi('Integral:alarms:list')")
    @GetMapping("/list")
    public TableDataInfo list(IntAlarms intAlarms)
    {
        startPage();
        List<IntAlarms> list = intAlarmsService.selectIntAlarmsList(intAlarms);
        return getDataTable(list);
    }

    /**
     * 导出报警信息表列表
     */
    @PreAuthorize("@ss.hasPermi('Integral:alarms:export')")
    @Log(title = "报警信息表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IntAlarms intAlarms)
    {
        List<IntAlarms> list = intAlarmsService.selectIntAlarmsList(intAlarms);
        ExcelUtil<IntAlarms> util = new ExcelUtil<IntAlarms>(IntAlarms.class);
        return util.exportExcel(list, "报警信息表数据");
    }

    /**
     * 获取报警信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('Integral:alarms:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(intAlarmsService.selectIntAlarmsById(id));
    }

    /**
     * 新增报警信息表
     */
    @PreAuthorize("@ss.hasPermi('Integral:alarms:add')")
    @Log(title = "报警信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IntAlarms intAlarms)
    {
        return toAjax(intAlarmsService.insertIntAlarms(intAlarms));
    }

    /**
     * 修改报警信息表
     */
    @PreAuthorize("@ss.hasPermi('Integral:alarms:edit')")
    @Log(title = "报警信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IntAlarms intAlarms)
    {
        return toAjax(intAlarmsService.updateIntAlarms(intAlarms));
    }

    /**
     * 删除报警信息表
     */
    @PreAuthorize("@ss.hasPermi('Integral:alarms:remove')")
    @Log(title = "报警信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(intAlarmsService.deleteIntAlarmsByIds(ids));
    }
}
